#pragma once 
#include <Windows.h>
#include <vector>

#include "../TinyXml/tinyxml.h"

using namespace std;

struct tFrame
{
	RECT rRenderRect;
	RECT rCollisionRect;
	RECT rActiveRect;
	POINT pAnchorPoint;
	float fTimer;
	int nNumber;
	string sEvent;
};

struct tAnimation
{
	string _name;
	bool _IsLooping;
	string _imgFilepath;
	vector<tFrame> _vFrames;

};

class cAnimationE
{
private:
	int m_nCurrFrame;
	//bool m_bIsLooping;
	bool m_bIsPlaying;
	int m_nImageID;

	vector<tAnimation> m_vAnimations;

public:
	void Play()
	{
		m_bIsPlaying=true;
	}
	void Stop()
	{
		m_bIsPlaying = false;
	}
	void Resume()
	{
		m_bIsPlaying = false;
	}
	void Reset()
	{
		m_nCurrFrame = 0;
	}

	tAnimation* GetAnimation(int i) {return &m_vAnimations[i];}
	vector<tAnimation>& GetList() {return m_vAnimations;}

	void SetIsPlaying(bool _b) { m_bIsPlaying = _b;}

	bool GetIsPlaying() {return m_bIsPlaying;}
	int GetFrameCount() {return m_nCurrFrame;}

	void Update(float _fDt);

	void Render( int _nPosX, int _nPosY, bool _bIsXFlipped, float _fScale, DWORD _dwcolor); 

	bool Load (const char*  sXmlFileName);
};